import handleArr from "./index";
let reducer = (
    state = {
        ...handleArr.state,
    }, //存放数据,
    action: { type: string; value: number }
) => {
    let newState = JSON.parse(JSON.stringify(state)); //深拷贝
    // switch (action.type) {
    //     case handleArr.sarrpush1: {
    //         handleArr.actions[handleArr.sarrpush1](newState, action);
    //         break;
    //     }
    //     default:
    //         break;
    // }

    // 优化上述代码 添加action不需要手动更改reducer代码
    for (let key in handleArr.actionNames) {
        if (action.type === key) {
            handleArr.actions[handleArr.actionNames[key]](newState, action);
            break;
        }
    }

    return newState;
};
export default reducer;
